package runload

/*
import (
	. "gitee.com/kingzyt/common/behaviorTree"
	"drawer"
	"fmt"
	"runtime"
)

var g_renderedNodeMarks = map[string]bool{}

func clear() {
	for k := range g_renderedNodeMarks {
		g_renderedNodeMarks[k] = false
	}
}

func GetShowNameRect(node INode) (w float32, h float32) {
	fw, fh := drawer.GetFontWH()
	return float32(fw*int32(len(node.GetName())) + 10), float32(fh + 3)
}

//横向放置子node
func GetShowRect(node INode) (w float32, h float32) {
	namew, nameh := GetShowNameRect(node)

	if node.GetChildCount() > 0 {
		node.IteratorChildren(func(child INode) bool {
			cw, ch := float32(0), float32(0)
			if child.GetType() == NodeType_Pass {
				cw, ch = GetShowNameRect(child)
			} else {
				cw, ch = GetShowRect(child)
			}

			checkSize(child.GetType().String()+"_"+child.GetName(), cw, ch)

			if w < cw {
				w = cw
			}
			h += ch
			return true
		})
	} else {
		h += nameh
	}

	w += namew
	return
}

func checkSize(name string, w float32, h float32) {
	fmt.Println(name, w, h)
	if w < 0 || h < 0 || w > 10000 || h > 10000 {
		panic(fmt.Errorf("%s: size err, w:%f, h:%f", name, w, h))
	}
}

func RenderNode(render *drawer.SimpleDrawer, node INode, runningNode INode, x float32, y float32) (h float32) {
	namew, nameh := GetShowNameRect(node)
	color := uint32(0xffffff)

	if g_renderedNodeMarks[node.GetName()] {
		if node.GetChildCount() > 0 {
			color = uint32(0xff0000)
		}

		if runningNode == node {
			color = 0x00ff00
		}
		render.RenderFont("*"+node.GetName()+"*", x, y, color)
		h += nameh
		return
	} else {
		if runningNode == node {
			color = 0x00ff00
		}
		render.RenderFont(node.GetName(), x, y, color)
	}

	g_renderedNodeMarks[node.GetName()] = true

	x += namew
	originx, originy := x-10, y
	if node.GetChildCount() > 0 {
		node.IteratorChildren(func(child INode) bool {
			color := uint32(0xffffff)
			if runningNode == child {
				color = 0x00ff00
			}
			render.RenderLine(originx, originy, x, y+h, color)

			h += RenderNode(render, child, runningNode, x, y+h)
			return true
		})
	} else {
		h += nameh
	}

	return
}

type BTViewer struct {
	*drawer.SimpleDrawer

	root INode

	runtimeData IRuntimeBTData

	flashLight bool
}

func NewBTViewer(name string, root INode, runtimeData IRuntimeBTData) *BTViewer {
	rlt := &BTViewer{
		root:        root,
		runtimeData: runtimeData,
	}

	rlt.SimpleDrawer = drawer.NewSimpleDrawer(name, nil, rlt.render)

	return rlt
}

func (self *BTViewer) render(drawer *drawer.SimpleDrawer) {
	self.flashLight = !self.flashLight
	if self.flashLight {
		drawer.RenderFont("*", 0, 0, 0xff0000)
	}

	var top INode
	var updateCnt int64

	func() {
		r := self.runtimeData.(IRobot)
		r.Lock()
		defer r.Unlock()

		top, _, _ = self.runtimeData.GetRuntimeNodeStack().GetTopNode()
		updateCnt = r.GetUpdateCnt()
	}()

	drawer.RenderFont(fmt.Sprintf("updateCnt:%d, goroutineCnt:%d", updateCnt, runtime.NumGoroutine()), 20, 0, 0xffffff)

	clear()
	RenderNode(drawer, self.root, top, 0, 20)
}
*/
